Dialogic Q&A
この記事を閲覧するにはアカウントが必要です。
コードから会話を生成
func show_textbox_from_gdscript():
# 1. Create a new Dialogic Timeline
var timeline : DialogicTimeline = DialogicTimeline.new()
# 2. Create Dialogic Text Events
var text_event1 = DialogicTextEvent.new()
text_event1.text = "Hello, adventurer! Welcome to our humble village."
# Optional: Load a character if you have one
text_event1.character = load("res://CharaSprite/Noto.dch")
var text_event2 = DialogicTextEvent.new()
text_event2.text = "How can I help you today?"
# Another way to create an event with character and text using string syntax
# (requires 'timeline.events_processed = false' or using the string array method below)
# var text_event3 = DialogicTextEvent.new()
# text_event3.text = "Hero: I need to save the world!"
# OR if loading a character resource:
# var hero_character = load("res://characters/Hero.dch")
# var text_event3 = DialogicTextEvent.new()
# text_event3.character = hero_character
# text_event3.text = "I need to save the world!"
# 3. Add events to an array and then to the timeline
var events : Array = []
events.append(text_event1)
events.append(text_event2)
# events.append(text_event3) # If you created text_event3 as a resource
timeline.events = events
timeline.events_processed = true # Important if you are adding DialogicTextEvent resources directly
# Alternative: Create an array of Strings directly (if you prefer timeline text syntax)
var events_from_string : Array = """
Villager: Hello, adventurer! Welcome to our humble village.
Villager: How can I help you today?
Hero: I need to save the world!
""".split('\n')
timeline.events = events_from_string
timeline.events_processed = false # This is the default when using string array, but good to be explicit
# 4. Start the timeline
Dialogic.start(timeline)
how to insert variables within text
To insert variables within text in Dialogic, you can use curly brackets {} around the variable name.
Here are the different ways to insert variables:
- Dialogic Variables: For a Dialogic variable, simply type its name inside curly brackets:
{variable_name}. - Variables in Folders: If a Dialogic variable is organized within a folder, specify the full path using dots:
{MyFolder.variable_name}or{FolderA.FolderB.variable_name}. - Autoload Variables and Methods: To use a variable from an Autoload, use the syntax
{AutoloadName.variable}. You can also call methods on that Autoload, and the method’s return value will be inserted into the text:{Autoload.get_random_name()}. - Simple Operations: You can even perform basic operations directly within the curly brackets, for instance:
{{Player.Health}/10.0+2}.
how to wait (punctuate) displaying text for a moment
The browsed page “Writing Texts” mentions “Text Effects”. It specifically states that [pause=x] “pauses x seconds”. This seems to be exactly what the user is asking for. The document also mentions “Text Modifiers” and “BBCode”, but “Text Effects” is the most relevant for pausing the display of text.
Therefore, to wait for a moment while displaying text in Dialogic, the [pause=x] text effect can be used, where x is the number of seconds to pause. You can find a list of all the text effects in the “Text Effects” section of the Dialogic documentation.
How to wave text
To wave text in Dialogic or Godot Engine, you can use the [wave] BBCode tag within a RichTextLabel node. Dialogic utilizes Godot’s BBCode capabilities for text styling and effects.
The [wave] tag has the following format: [wave amp={amplitude} freq={frequency} connected={0_or_1}]{text}[/wave].
Here’s how the parameters work:
amp(amplitude): This controls how high and low the text waves. A higher value will result in a more pronounced up-and-down movement.freq(frequency): This parameter determines how fast the text moves up and down. A value of0will prevent any visible waves, and negative values will also not display waves.connected: If set to1(the default), glyphs with ligatures (characters that are joined together) will move as a single unit. If set to0, each glyph will move individually, which can help with certain rendering issues.
For example, to make text wave with an amplitude of 50 and a frequency of 5, you would use: [wave amp=50.0 freq=5.0]Your waving text here[/wave].
Godot’s RichTextLabel also offers other built-in text effects such as [pulse] for a pulsing effect, [tornado] for circular movement, [shake] for shaking text, [fade] for a static fade, and [rainbow] for changing text color over time. You can also create custom text effects by extending the RichTextEffect resource type.
Comments ( 0 )
No comments yet.